<!--
 * @Author: 刘十三
 * @Date: 2024-01-04 13:02:36
 * @LastEditors: 刘十三
 * @LastEditTime: 2024-01-07 00:21:55
 * @FilePath: \dev-1.3.1-nm\dev\pages\internal\linkage\components\taskSetList.vue
 * @Description: 内蒙多员联动 - 延期办理申请（任务选择列表）
-->

<template>
  <view class="page">
    <!-- #ifdef H5-ONLY -->
    <theme-navbar :is-white="false" :title="navTitle" :custom-back="goBack" style="z-index: 99999">
      <u-icon name="search" color="#FFF" size="38" style="margin: 0 24rpx 0 6rpx" @tap="openSearch"></u-icon>
    </theme-navbar>
    <!-- #endif -->

    <!-- #ifdef H5-WECHAT -->
    <fab-button :content="fContent" @fabtrigger="fabtrigger" />
    <!-- #endif -->

    <!-- 列表 -->
    <view class="content">
      <me-table :i="0" :index="0" :top="20" :load-data="loadData" :init-load="false" ref="mescrollItem0">
        <template slot-scope="d">
          <view style="margin-bottom: 20rpx;">
            <u-card :showHead="false" :showFoot="false" padding="20" :border="false" margin="0">
              <taskSetItem slot="body" class="n-lay" :seal-info="d.data" />
            </u-card>
          </view>
        </template>
      </me-table>
    </view>

    <!-- 搜索条件 -->
    <u-popup v-model="searchVisable" width="80%" mode="right">
      <view class="cearch_title">
        查询条件
      </view>
      <u-form :model="serachForm" label-position="top" label-width="auto" style="padding: 80rpx 32rpx 0 32rpx" ref="uForm">
        <template v-if="searchVisable">
          <u-form-item label="检索内容:" prop="taskTitle">
            <u-input placeholder="请输入检索内容" :border="false" v-model="serachForm.taskQueryRequest.taskTitle" />
          </u-form-item>
          <u-form-item label="企业字号:" prop="retailerName">
            <u-input placeholder="请输入企业字号" :border="false" v-model="serachForm.taskQueryRequest.retailerName" />
          </u-form-item>
          <u-form-item label="反馈开始日期:" prop="feedbackDateStart">
            <z-date placeholder="请选择" v-model="serachForm.taskQueryRequest.feedbackDateStart" />
          </u-form-item>
          <u-form-item label="反馈结束日期:" prop="feedbackDateEnd">
            <z-date placeholder="请选择" v-model="serachForm.taskQueryRequest.feedbackDateEnd" />
          </u-form-item>
        </template>
      </u-form>
      <view class="submit-btns btn-other-cls">
        <u-button plain class="del" type="primary" @tap="handleRest">
          重置
        </u-button>
        <u-button class="mit" type="primary" @tap="selectChange">
          确定
        </u-button>
      </view>
    </u-popup>
  </view>
</template>

<script>
import { ZDate } from "@/components";
import meTable from "@/components/me-table.vue";
import fabButton from "@/components/uni-fab.vue";
import taskSetItem from "./taskSetItem.vue";
import MescrollMoreMixin from "@/components/mescroll-uni/mixins/mescroll-more.js";
import linkageService from "@/service/internal/linkeage.service";
export default {
  components: {
    ZDate,
    meTable,
    fabButton,
    taskSetItem,
  },
  mixins: [MescrollMoreMixin],
  data() {
    return {
      searchVisable: false,
      serachForm: {
        page: 1,
        limit: 10,
        taskQueryRequest: {
          feedbackDateStart: "",
          feedbackDateEnd: "",
          retailerName: "",
          taskTitle: "",
        },
      },
      fContent: [
        {
          iconPath: require("@/static/search.png"),
          selectedIconPath: require("@/static/search.png"),
          text: "搜索",
          active: false,
        },
      ],
    };
  },
  methods: {
    openSearch() {
      this.searchVisable = true;
    },
    selectChange() {
      if (this.serachForm.taskQueryRequest.feedbackDateStart && this.serachForm.taskQueryRequest.feedbackDateEnd) {
        if (new Date(this.serachForm.taskQueryRequest.feedbackDateStart) > new Date(this.serachForm.taskQueryRequest.feedbackDateEnd)) {
          return this.$u.toast("反馈开始日期不能大于反馈结束日期");
        }
      }
      this.searchVisable = false;
      this.handleReferList();
    },
    handleRest() {
      this.serachForm.taskQueryRequest = {
        feedbackDateStart: "",
        feedbackDateEnd: "",
        retailerName: "",
        taskTitle: "",
      };
    },
    loadData(pager) {
      let self = this;
      this.serachForm.page = pager.num;
      this.serachForm.limit = pager.size;
      return new Promise((resolve) => {
        linkageService
          .getSelectTaskPageList(self.serachForm)
          .then((res) => {
            if (res.success) {
              resolve({
                data: res.data,
                count: res.count,
              });
            } else {
              self.$modal.alert(res.msg);
              resolve({
                data: [],
                count: 0,
              });
            }
          })
          .catch((err) => {
            resolve({
              data: [],
              count: 0,
            });
          });
      });
    },

    fabtrigger(btn) {
      if (btn.index == 0) {
        this.openSearch();
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.page {
  padding: 0;
}
.content {
  padding: 0 24rpx;
  background: #f5f5f5;
}
.swipe-list {
  background: #ffffff;
  margin-bottom: 24rpx;
  overflow: hidden;
  border-radius: 5px;
}

.cearch_title {
  background-color: #f3f4f5;
  width: 100%;
  height: 82rpx;
  font-size: 32rpx;
  font-weight: 600;
  padding: 22rpx 0 21rpx 32rpx;
  z-index: 999;
  position: fixed;
}
</style>
